#
#Political Shocks and Asset Prices
#
# Replication file
# 
#Code to generate p-values using empirical distribution
#
# Note that because of the simulation strategy, the obtained p-values may not be exactly like the ones reported in the paper. But, they should be within one or two decimals from them.
# 
# Version July 28 2021 
#
#
rm(list=ls(all=TRUE))
#
library(foreign)
library(lmtest)
library(sandwich)
#
#
# Set Directory Path - You will need to change accordingly
#
setwd("/Users/ssaiegh/Files/Mac/UCSD/Carnahan/Shocks/Replication Files")
#
# Read Data File -- This file contains the volatility ratios for all non-event dates.
#
data <-read.dta("one_day_loop.dta")
attach(data,warn.conflicts=FALSE)
#
# **** TABLE 2 ****
#
# **** NOMINAL RETURNS **** 
#
# Set the Number of Events to be Seeded 
#
# **** ALL EVENTS ****
#
n <- 125
#
#
# The following Loop generates the simulated t-values
#
bstrap <- c()
for (i in 1:10000){
newsample <- sample(ratio_nom, n, replace=T)
bstrap <- c(bstrap, mean(newsample)/(sd(newsample)/sqrt(n)))
}
# 
# The final step is to compare the simulated t-values with those of the event-days reported in Tables 2 and 3.
#
# Pre-Event Volatility P-value
#
(sum(bstrap >0.093)/100)/100
#
#Post-Event Volatility P-Value
#
(sum(bstrap > 4.239)/100)/100
#
# **** CHANGE IN ECONOMIC STEWARDSHIP **** 
#
n <- 62
#
# The following Loop generates the simulated t-values
#
bstrap <- c()
for (i in 1:10000){
newsample <- sample(ratio_nom, n, replace=T)
bstrap <- c(bstrap, mean(newsample)/(sd(newsample)/sqrt(n)))
}
# 
#
# Pre-Event Volatility P-value
#
(sum(bstrap >0.398)/100)/100
#
#Post-Event Volatility P-Value
#
(sum(bstrap > 3.731)/100)/100
#
# **** CHANGE IN ECONOMIC STEWARDSHIP (SAME GOVERNMENT)**** 
#
n <- 47
#
# The following Loop generates the simulated t-values
#
bstrap <- c()
for (i in 1:10000){
newsample <- sample(ratio_nom, n, replace=T)
bstrap <- c(bstrap, mean(newsample)/(sd(newsample)/sqrt(n)))
}
# 
#
# Pre-Event Volatility P-value
#
(sum(bstrap >0.681)/100)/100
#
#Post-Event Volatility P-Value
#
(sum(bstrap > 3.304)/100)/100
#
# **** CHANGE IN ADMINISTRATION **** 
#
n <- 21
#
#
# The following Loop generates the simulated t-values
#
bstrap <- c()
for (i in 1:10000){
newsample <- sample(ratio_nom, n, replace=T)
bstrap <- c(bstrap, mean(newsample)/(sd(newsample)/sqrt(n)))
}
# 
#
# Pre-Event Volatility P-value
#
(sum(bstrap >-2.698)/100)/100
#
#Post-Event Volatility P-Value
#
(sum(bstrap > 2.235)/100)/100
#
# **** IRREGULAR CHANGE IN ADMINISTRATION **** 
#
n <- 9
#
#
# The following Loop generates the simulated t-values
#
bstrap <- c()
for (i in 1:10000){
newsample <- sample(ratio_nom, n, replace=T)
bstrap <- c(bstrap, mean(newsample)/(sd(newsample)/sqrt(n)))
}
# 
#
# Pre-Event Volatility P-value
#
(sum(bstrap >-1.432)/100)/100
#
#Post-Event Volatility P-Value
#
(sum(bstrap > 2.367)/100)/100
#
# **** PLANNED SUCCESSION **** 
#
n <- 12
#
#
# The following Loop generates the simulated t-values
#
bstrap <- c()
for (i in 1:10000){
newsample <- sample(ratio_nom, n, replace=T)
bstrap <- c(bstrap, mean(newsample)/(sd(newsample)/sqrt(n)))
}
# 
#
# Pre-Event Volatility P-value
#
(sum(bstrap >-2.272)/100)/100
#
#Post-Event Volatility P-Value
#
(sum(bstrap > 0.684)/100)/100
#
# **** NATIONAL ELECTION **** 
#
n <- 28
#
#
# The following Loop generates the simulated t-values
#
bstrap <- c()
for (i in 1:10000){
newsample <- sample(ratio_nom, n, replace=T)
bstrap <- c(bstrap, mean(newsample)/(sd(newsample)/sqrt(n)))
}
# 
#
# Pre-Event Volatility P-value
#
(sum(bstrap >0.739)/100)/100
#
#Post-Event Volatility P-Value
#
(sum(bstrap > 2.426)/100)/100
#
# **** TERRORIST ACT **** 
#
n <- 27
#
#
# The following Loop generates the simulated t-values
#
bstrap <- c()
for (i in 1:10000){
newsample <- sample(ratio_nom, n, replace=T)
bstrap <- c(bstrap, mean(newsample)/(sd(newsample)/sqrt(n)))
}
# 
#
# Pre-Event Volatility P-value
#
(sum(bstrap >-1.897)/100)/100
#
#Post-Event Volatility P-Value
#
(sum(bstrap > -1.765)/100)/100
#
# **** INFLATION ADJUSTED RETURNS **** 
#
# Set the Number of Events to be Seeded 
#
# **** ALL EVENTS ****
#
n <- 125
#
#
# The following Loop generates the simulated t-values
#
bstrap <- c()
for (i in 1:10000){
newsample <- sample(ratio_inf, n, replace=T)
bstrap <- c(bstrap, mean(newsample)/(sd(newsample)/sqrt(n)))
}
# 
#
# Pre-Event Volatility P-value
#
(sum(bstrap >0.713)/100)/100
#
#Post-Event Volatility P-Value
#
(sum(bstrap > 3.793)/100)/100
#
# **** CHANGE IN ECONOMIC STEWARDSHIP **** 
#
n <- 62
#
# The following Loop generates the simulated t-values
#
bstrap <- c()
for (i in 1:10000){
newsample <- sample(ratio_inf, n, replace=T)
bstrap <- c(bstrap, mean(newsample)/(sd(newsample)/sqrt(n)))
}
# 
#
# Pre-Event Volatility P-value
#
(sum(bstrap >-0.824)/100)/100
#
#Post-Event Volatility P-Value
#
(sum(bstrap > 2.881)/100)/100
#
# **** CHANGE IN ECONOMIC STEWARDSHIP (SAME GOVERNMENT)**** 
#
n <- 47
#
# The following Loop generates the simulated t-values
#
bstrap <- c()
for (i in 1:10000){
newsample <- sample(ratio_inf, n, replace=T)
bstrap <- c(bstrap, mean(newsample)/(sd(newsample)/sqrt(n)))
}
# 
#
# Pre-Event Volatility P-value
#
(sum(bstrap >-0.553)/100)/100
#
#Post-Event Volatility P-Value
#
(sum(bstrap > 2.576)/100)/100
#
# **** CHANGE IN ADMINISTRATION **** 
#
n <- 21
#
#
# The following Loop generates the simulated t-values
#
bstrap <- c()
for (i in 1:10000){
newsample <- sample(ratio_inf, n, replace=T)
bstrap <- c(bstrap, mean(newsample)/(sd(newsample)/sqrt(n)))
}
# 
#
# Pre-Event Volatility P-value
#
(sum(bstrap >-3.192)/100)/100
#
#Post-Event Volatility P-Value
#
(sum(bstrap > 1.888)/100)/100
#
# **** IRREGULAR CHANGE IN ADMINISTRATION **** 
#
n <- 9
#
#
# The following Loop generates the simulated t-values
#
bstrap <- c()
for (i in 1:10000){
newsample <- sample(ratio_inf, n, replace=T)
bstrap <- c(bstrap, mean(newsample)/(sd(newsample)/sqrt(n)))
}
# 
#
# Pre-Event Volatility P-value
#
(sum(bstrap >-1.062)/100)/100
#
#Post-Event Volatility P-Value
#
(sum(bstrap > 2.411)/100)/100
#
# **** PLANNED SUCCESSION **** 
#
n <- 12
#
#
# The following Loop generates the simulated t-values
#
bstrap <- c()
for (i in 1:10000){
newsample <- sample(ratio_inf, n, replace=T)
bstrap <- c(bstrap, mean(newsample)/(sd(newsample)/sqrt(n)))
}
# 
#
# Pre-Event Volatility P-value
#
(sum(bstrap >-4.087)/100)/100
#
#Post-Event Volatility P-Value
#
(sum(bstrap > -1.366)/100)/100
#
# **** NATIONAL ELECTION **** 
#
n <- 28
#
#
# The following Loop generates the simulated t-values
#
bstrap <- c()
for (i in 1:10000){
newsample <- sample(ratio_inf, n, replace=T)
bstrap <- c(bstrap, mean(newsample)/(sd(newsample)/sqrt(n)))
}
# 
#
# Pre-Event Volatility P-value
#
(sum(bstrap >1.087)/100)/100
#
#Post-Event Volatility P-Value
#
(sum(bstrap > 1.965)/100)/100
#
# **** TERRORIST ACT **** 
#
n <- 27
#
#
# The following Loop generates the simulated t-values
#
bstrap <- c()
for (i in 1:10000){
newsample <- sample(ratio_inf, n, replace=T)
bstrap <- c(bstrap, mean(newsample)/(sd(newsample)/sqrt(n)))
}
# 
#
# Pre-Event Volatility P-value
#
(sum(bstrap >-3.696)/100)/100
#
#Post-Event Volatility P-Value
#
(sum(bstrap > 1.076)/100)/100
#
# **** REAL RETURNS IN US DOLLARS **** 
#
# Set the Number of Events to be Seeded 
#
# **** ALL EVENTS ****
#
n <- 125
#
#
# The following Loop generates the simulated t-values
#
bstrap <- c()
for (i in 1:10000){
newsample <- sample(ratio_dol, n, replace=T)
bstrap <- c(bstrap, mean(newsample)/(sd(newsample)/sqrt(n)))
}
# 
#
# Pre-Event Volatility P-value
#
(sum(bstrap >0.282)/100)/100
#
#Post-Event Volatility P-Value
#
(sum(bstrap > 4.719)/100)/100
#
# **** CHANGE IN ECONOMIC STEWARDSHIP **** 
#
n <- 62
#
# The following Loop generates the simulated t-values
#
bstrap <- c()
for (i in 1:10000){
newsample <- sample(ratio_dol, n, replace=T)
bstrap <- c(bstrap, mean(newsample)/(sd(newsample)/sqrt(n)))
}
# 
#
# Pre-Event Volatility P-value
#
(sum(bstrap >0.859)/100)/100
#
#Post-Event Volatility P-Value
#
(sum(bstrap > 3.914)/100)/100
#
# **** CHANGE IN ECONOMIC STEWARDSHIP (SAME GOVERNMENT)**** 
#
n <- 47
#
# The following Loop generates the simulated t-values
#
bstrap <- c()
for (i in 1:10000){
newsample <- sample(ratio_dol, n, replace=T)
bstrap <- c(bstrap, mean(newsample)/(sd(newsample)/sqrt(n)))
}
# 
#
# Pre-Event Volatility P-value
#
(sum(bstrap >1.039)/100)/100
#
#Post-Event Volatility P-Value
#
(sum(bstrap > 3.372)/100)/100
#
# **** CHANGE IN ADMINISTRATION **** 
#
n <- 21
#
#
# The following Loop generates the simulated t-values
#
bstrap <- c()
for (i in 1:10000){
newsample <- sample(ratio_dol, n, replace=T)
bstrap <- c(bstrap, mean(newsample)/(sd(newsample)/sqrt(n)))
}
# 
#
# Pre-Event Volatility P-value
#
(sum(bstrap >-1.381)/100)/100
#
#Post-Event Volatility P-Value
#
(sum(bstrap > 2.310)/100)/100
#
# **** IRREGULAR CHANGE IN ADMINISTRATION **** 
#
n <- 9
#
#
# The following Loop generates the simulated t-values
#
bstrap <- c()
for (i in 1:10000){
newsample <- sample(ratio_dol, n, replace=T)
bstrap <- c(bstrap, mean(newsample)/(sd(newsample)/sqrt(n)))
}
# 
#
# Pre-Event Volatility P-value
#
(sum(bstrap >-1.703)/100)/100
#
#Post-Event Volatility P-Value
#
(sum(bstrap > 2.130)/100)/100
#
# **** PLANNED SUCCESSION **** 
#
n <- 12
#
#
# The following Loop generates the simulated t-values
#
bstrap <- c()
for (i in 1:10000){
newsample <- sample(ratio_dol, n, replace=T)
bstrap <- c(bstrap, mean(newsample)/(sd(newsample)/sqrt(n)))
}
# 
#
# Pre-Event Volatility P-value
#
(sum(bstrap >-0.568)/100)/100
#
#Post-Event Volatility P-Value
#
(sum(bstrap > 1.193)/100)/100
#
# **** NATIONAL ELECTION **** 
#
n <- 28
#
#
# The following Loop generates the simulated t-values
#
bstrap <- c()
for (i in 1:10000){
newsample <- sample(ratio_dol, n, replace=T)
bstrap <- c(bstrap, mean(newsample)/(sd(newsample)/sqrt(n)))
}
# 
#
# Pre-Event Volatility P-value
#
(sum(bstrap >0.265)/100)/100
#
#Post-Event Volatility P-Value
#
(sum(bstrap > 2.495)/100)/100
#
# **** TERRORIST ACT **** 
#
n <- 27
#
#
# The following Loop generates the simulated t-values
#
bstrap <- c()
for (i in 1:10000){
newsample <- sample(ratio_dol, n, replace=T)
bstrap <- c(bstrap, mean(newsample)/(sd(newsample)/sqrt(n)))
}
# 
#
# Pre-Event Volatility P-value
#
(sum(bstrap >-1.022)/100)/100
#
#Post-Event Volatility P-Value
#
(sum(bstrap > 0.887)/100)/100
#
